package com.framework.controller.yhbcontroller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.*;
import com.framework.yhbEntity.Index.YhbIndex;
import com.framework.yhbEntity.Index.YhbIndexMenu;
import com.framework.yhbEntity.Index.YhbOrAppAdv;
import com.framework.yhbEntity.Index.YhbServiceMenu;
import com.framework.yhbEntity.notice.YhbNotice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 首页相关数据信息
 */
@RestController
@RequestMapping("index")
@Api(value="首页模块",tags={"首页模块"})
public class YhbIndexController {

    @Autowired
    private YhbIndexService yhbIndexService;

    @Autowired
    private YhbIndexMenuService yhbIndexMenuService;

    @Autowired
    private YhbNoticeService yhbNoticeService;

    @Autowired
    private YhbServiceMenuSerivce yhbServiceMenuSerivce;

    @Autowired
    private YhbOrAppAdvService yhbOrAppAdvService;

    /**
     * 获取首页轮播图
     * @param token
     * @return
     */
    @GetMapping("/user/getIndexBanner")
    @ApiOperation("首页轮播图")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query",required = true),
            @ApiImplicitParam(name="type",value = "类型",dataType="String", paramType = "query",required = true)
    })
    public RespResult getIndexBanner(String token,String type){
       List<YhbIndex> list= yhbIndexService.getIndexBanner(token,type);
        return  RespResult.ok().put("bannerList",list);
    }

    /**
     * 获取首页按钮图标
     * @param token
     * @return
     */
    @GetMapping("/user/getIndexMenu")
    @ApiOperation("首页按钮")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query",required = true)
    })
    public RespResult getIndexMenu(String token){
        List<YhbIndexMenu> list=yhbIndexMenuService.getIndexMenu(token);
        return RespResult.ok().put("menuList",list);

    }

    /**
     * 首页通知
     * @param token
     * @return
     */
    @GetMapping("/user/getIndexNotice")
    @ApiOperation("首页通知")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query",required = true)
    })
    public RespResult getIndexNotice(String token){
        List<YhbNotice> list=yhbNoticeService.getIndexNotice(token);
        return  RespResult.ok().put("noticeList",list);
    }

    @GetMapping("/user/getIndexInfo")
    @ApiOperation("首页相关信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query",required = true)
    })
    public RespResult getIndexInfo(String token){
        Map<String,Object> map=yhbIndexService.queryIndexInfo(token);
        return RespResult.ok(map);
    }

    @GetMapping("user/getServiceMenu")
    @ApiOperation("业务菜单")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query",required = true)
    })
    public RespResult getServiceMenu(String token){
        List<YhbServiceMenu> list=yhbServiceMenuSerivce.getServiceMenu(token);
        return RespResult.ok().put("list",list);
    }


    @GetMapping("user/getIndexAdv")
    @ApiOperation("首页弹窗")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query",required = true)
    })
    public RespResult getIndexAdv(String token){
        List<YhbOrAppAdv> list=yhbOrAppAdvService.getIndexAdv(token);
        return RespResult.ok().put("list",list);
    }


}
